package com.hzncc.scaffold.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.hzncc.scaffold.entity.Bo.MyExamBo;
import com.hzncc.scaffold.entity.Bo.MyExamInvigilationBo;
import com.hzncc.scaffold.entity.Bo.OnePlusXExamListBo;
import com.hzncc.scaffold.entity.Bo.OnePlusxExamDetailBo;
import com.hzncc.scaffold.entity.Other.Oneplusxexam;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 * 1+X考试表 Mapper 接口
 * </p>
 *
 * @author DrunkBear
 * @since 2022-04-27
 */
@Component
public interface OneplusxexamMapper extends BaseMapper<Oneplusxexam> {

    @Select("SELECT\n" +
            "\t`examineeapply`.`id`,\n" +
            "\t`examineeapply`.`finalCheck`,\n" +
            "\t`oneplusxexam`.`id` AS `onePlusXExamId`,\n" +
            "\t`oneplusxexam`.`title` AS `onePlusXExamTitle`,\n" +
            "\t`oneplusxexam`.`startTime` AS `onePlusXExamStartTime`,\n" +
            "\t`oneplusxexam`.`endTime` AS `onePlusXExamEndTime` \n" +
            "FROM\n" +
            "\t`examineeapply` AS `examineeapply` LEFT OUTER JOIN `oneplusxexam` AS `oneplusxexam` ON `examineeapply`.`examId` = `oneplusxexam`.`id` ${ew.customSqlSegment}")
    public List<MyExamBo> myExam(@Param(Constants.WRAPPER) QueryWrapper queryWrapper);


    @Select("SELECT\n" +
            "\t`invigilatorconfirm`.`id`,\n" +
            "\t`invigilatorconfirm`.`status`,\n" +
            "\t`invigilatorconfirm`.`title`,\n" +
            "\t`oneplusxexam`.`id` AS `onePlusXExamId`,\n" +
            "\t`oneplusxexam`.`title` AS `onePlusXExamTitle`,\n" +
            "\t`oneplusxexam`.`startTime` AS `onePlusXExamStartTime`,\n" +
            "\t`oneplusxexam`.`endTime` AS `onePlusXExamEndTime` \n" +
            "FROM\n" +
            "\t`invigilatorconfirm` AS `invigilatorconfirm`\n" +
            "\tLEFT OUTER JOIN `oneplusxexam` AS `oneplusxexam` ON `invigilatorconfirm`.`examId` = `oneplusxexam`.`id` ${ew.customSqlSegment}")
    public List<MyExamInvigilationBo> myInvigilation(@Param(Constants.WRAPPER) QueryWrapper queryWrapper);



    @Select("SELECT\n" +
            "\t`oneplusxexam`.`id`,\n" +
            "\t`oneplusxexam`.`title`,\n" +
            "\t`oneplusxexam`.`startTime`,\n" +
            "\t`oneplusxexam`.`createTime`,\n" +
            "\t`oneplusxexam`.`endTime`,\n" +
            "\t`oneplusxexam`.`examType`,\n" +
            "\t`oneplusxexam`.`device`,\n" +
            "\t`oneplusxexam`.`deviceType`,\n" +
            "\t`oneplusxexam`.`examineeAmount`,\n" +
            "\t`oneplusxexam`.`info`,\n" +
            "\t`oneplusxexam`.`activityStart`,\n" +
            "\t`oneplusxexam`.`activityEnd`,\n" +
            "\t`oneplusxexam`.`coordinate`,\n" +
            "\t`profession`.`id` AS `professionId`,\n" +
            "\t`profession`.`name` AS `professionName`,\n" +
            "\t`skill`.`id` AS `skillId`,\n" +
            "\t`skill`.`name` AS `skillName`\n" +
            "FROM\n" +
            "\t`oneplusxexam` AS `oneplusxexam`\n" +
            "\tLEFT OUTER JOIN `profession` AS `profession` ON `oneplusxexam`.`professionId` = `profession`.`id`\n" +
            "\tLEFT OUTER JOIN `skill` AS `skill` ON `oneplusxexam`.`skillId` = `skill`.`id` ${ew.customSqlSegment}")
    public OnePlusxExamDetailBo myOnePlusxExam(@Param(Constants.WRAPPER) QueryWrapper queryWrapper);


    @Select("SELECT\n" +
            "\t`oneplusxexam`.*,\n" +
            "\t`profession`.`name` AS `professionName`,\n" +
            "\t`skill`.`name` AS `skillName` \n" +
            "FROM\n" +
            "\t(\n" +
            "\tSELECT\n" +
            "\t\t`oneplusxexam`.`id`,\n" +
            "\t\t`oneplusxexam`.`title`,\n" +
            "\t\t`oneplusxexam`.`startTime`,\n" +
            "\t\t`oneplusxexam`.`endTime`,\n" +
            "\t\t`oneplusxexam`.`activityStart`,\n" +
            "\t\t`oneplusxexam`.`activityEnd`,\n" +
            "\t\t`oneplusxexam`.`examineeAmount`,\n" +
            "\t\t`oneplusxexam`.`examType`,\n" +
            "\t\t`oneplusxexam`.`status`,\n" +
            "\t\t`oneplusxexam`.`createTime`,\n" +
            "\t\t`oneplusxexam`.`isCommitted`,\n" +
            "\t\t`oneplusxexam`.`info`,\n" +
            "\t\t`oneplusxexam`.`device`,\n" +
            "\t\t`oneplusxexam`.`deviceType`,\n" +
            "\t\t`oneplusxexam`.`professionId`,\n" +
            "\t\t`oneplusxexam`.`skillId` \n" +
            "\tFROM\n" +
            "\t\t`oneplusxexam` AS `oneplusxexam` \n ${ew.customSqlSegment}" +
            "\tORDER BY\n" +
            "\t\t`oneplusxexam`.`createTime` DESC ) AS `oneplusxexam`\n" +
            "\tLEFT OUTER JOIN `profession` AS `profession` ON `oneplusxexam`.`professionId` = `profession`.`id`\n" +
            "\tLEFT OUTER JOIN `skill` AS `skill` ON `oneplusxexam`.`skillId` = `skill`.`id` \n" +
            "ORDER BY\n" +
            "\t`oneplusxexam`.`createTime` DESC")
    public List<OnePlusXExamListBo> listBo(@Param(Constants.WRAPPER) QueryWrapper queryWrapper);
}
